package com.erclab.xbuilder.formelements;

import com.erclab.internal.xpresso.formelements.Hidden;
import com.erclab.internal.xpresso.forms.Form;
import com.erclab.xbuilder.Xbuilder;
import com.erclab.xbuilder.exception.XBuilderException;
import com.erclab.xbuilder.managers.XBFormManager;

public class DestinationTableCreator extends Hidden {

	@Override
	public String[] processSubmittedValues(Form theForm, String[] submittedValues) {
		return new String[]{getTableName(theForm)};
	}	
	
	protected String getTableName(Form theForm) {
		XBFormManager fm = Xbuilder.getFormManager();
		String formName = null;
		try {
			formName = fm.getFormName(theForm.getFormParameters().getUniqueKeyValue());
		} catch (XBuilderException e) {
			// TODO: This should not be like this
		}
		
		return theForm.getFormParameters().getUser().getUserName() + "_" + formName; 
				
		
	}	
	
}
